package com.engine.salary.formlua.entity.standard;

import com.ql.util.express.IExpressContext;

import java.io.Serializable;
import java.math.BigDecimal;

public class ExcelResult implements Serializable {
    private static final long serialVersionUID = 4578033427466119428L;


    /**
     * 执行语句
     */
    private String express;

    /**
     * 上下文
     */
    private IExpressContext<String, Object> expressContext;

    /**
     * 文本、数字、日期从这里取值
     */
    private Object data;
    /**
     * 布尔值从这里取值
     */
    private boolean boolData;
    private String stringData;
    private BigDecimal numberData;
    /**
     * 执行状态，true为执行成功，false为执行失败
     */
    private boolean status;
    private String errorMsg;
    private String formulaId;
    private String dataType;


    /**
     * 运行时间
     */
    private long runTime;

    public ExcelResult() {
    }

    public ExcelResult(boolean status, Object data, String errorMsg) {
        this.status = status;
        this.data = data;
        this.errorMsg = errorMsg;
    }

    public String getExpress() {
        return express;
    }

    public void setExpress(String express) {
        this.express = express;
    }

    public IExpressContext<String, Object> getExpressContext() {
        return expressContext;
    }

    public void setExpressContext(IExpressContext<String, Object> expressContext) {
        this.expressContext = expressContext;
    }


    public String getDataType() {
        return dataType;
    }

    public void setDataType(String dataType) {
        this.dataType = dataType;
    }

    public String getFormulaId() {
        return formulaId;
    }

    public void setFormulaId(String formulaId) {
        this.formulaId = formulaId;
    }

    public boolean isBoolData() {
        return boolData;
    }

    public String getStringData() {
        return stringData;
    }

    public void setStringData(String stringData) {
        this.stringData = stringData;
    }

    public BigDecimal getNumberData() {
        return numberData;
    }

    public void setNumberData(BigDecimal numberData) {
        this.numberData = numberData;
    }

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    public boolean getBoolData() {
        return boolData;
    }

    public void setBoolData(boolean boolData) {
        this.boolData = boolData;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public boolean isStatus() {
        return status;
    }

    public void setStatus(boolean status) {
        this.status = status;
    }

    public long getRunTime() {
        return runTime;
    }

    public void setRunTime(long runTime) {
        this.runTime = runTime;
    }

    public String getData2String() {
        if (data == null) {
            return "";
        } else {
            if (data instanceof BigDecimal) {
                return ((BigDecimal) data).toPlainString();
            } else {
                return data.toString();
            }
        }
    }

    @Override
    public String toString() {
        return "ExcelResult{" +
                "express='" + express + '\'' +
                ", expressContext=" + expressContext +
                ", data=" + data +
                ", boolData=" + boolData +
                ", stringData='" + stringData + '\'' +
                ", numberData=" + numberData +
                ", status=" + status +
                ", errorMsg='" + errorMsg + '\'' +
                ", formulaId='" + formulaId + '\'' +
                ", dataType='" + dataType + '\'' +
                '}';
    }
}
